import { defineConfig,loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite'
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'
import path from 'path'

// https://vitejs.dev/config/
export default defineConfig( ({ mode, command }) => {
  return {
  plugins: [vue(),
    Components({resolvers:[AntDesignVueResolver(),],}),
  ],
  resolve:{
    alias:{
      '@': path.resolve(__dirname, 'src'),
    }
  },
  server: {
    cors: true,
    open: true,
    proxy: {
      '/api': {
          target: loadEnv(mode, process.cwd()).VITE_WEB_URL,   //代理接口
          changeOrigin: true,
          rewrite: (path) => path.replace(/^\/api/, '')
      }
    }
  },
}

});
